#!/usr/bin/octave -qp /home/trflp/web/lib/octave

arg = argv;
sample = load("-ascii", arg{1});

				# calculate the optimal smoothing parameters by setting
				# the order to a fixed value and optimizing the window until
				# the Durbin-Watson statistic approaches the value of 2,
				# indicating zero correlation between adjacent data points

height = max(sample(floor(end/3):end)); # discards leading garbage by picking 
                                          # the highest peak in the last two-thirds of the standard
quantum = height/10;
threshold = 2*quantum*abs((sort(floor(sample ./ quantum)))(floor(end/2)));
sample(find(sample < threshold)) = 0;
save -ascii - sample;
